import request from "@/utils/request";
import axios from 'axios'
//最新文章
export const getlist=async(page:number,pageSize:number)=>{
  return await request.get('https://bjwz.bwie.com/wipi/api/article',{
    params:{
      page,pageSize
    }
  })
}
export const editdel=async(payload:any)=>{
  console.log(payload);

  return await request.delete(`https://bjwz.bwie.com/wipi/api/article/${payload}`,{
    params:{
      payload
    }
  })
}
//最新评论
export const getcomment=async()=>{
  return await request.get('https://bjwz.bwie.com/wipi/api/comment')
}

//通过未通过
export const commshow=async(id:string,pass:boolean)=>{
  return await request.patch(`https://bjwz.bwie.com/wipi/api/comment/${id}`,{
    pass
  })
}
//删除
export const getdelete=(id:string)=>{
  return  request(`https://bjwz.bwie.com/wipi/api/comment/${id}`,{
    method:"delete",
  params:{
    id
  }
  })
}
//添加
export const getpush=(payload:any)=>{
  return  request(`https://bjwz.bwie.com/wipi/api/comment`,{
    method:"post",
    headers:{
      authorization:"Bearer" + localStorage.getItem('token')
    },
    data:payload
  })
}
//编辑
export const getedit=(payload:any)=>{
  console.log(payload);
  const {id,title,content}=payload
  return  request(`https://bjwz.bwie.com/wipi/api/article/${id}`,{
    method:"patch",
    headers:{
      authorization:"Bearer" + localStorage.getItem('token')
    },
    data:{
      content,title,id
    }
  })
}
export const get_work=async(page:number,pageSize:number)=>{
  return await  request.get('/api/comment',{
   params:{
     page,pageSize
   }
  })
        
 }
 
 // 最新文章
 export const get_article = async(page:number,pageSize:number)=>{
   return await request.get("/api/article",{
     params:{
       page,pageSize
     }
   })
 }
 
 //通过 || 拒绝
 
 export const get_through = async(id:string,pass:boolean) =>{
   return await request.patch(`/api/comment/${id}`,{
     pass
   })
 }
 
 //回复
 export const get_reply = async(payload:any) =>{
 return await request.post(`http://111.67.198.176:8103/api/comment`,{...payload})
 }
 
 //删除
 
 export const get_del = async(id:string) =>{
   return await  request.delete(`http://111.67.198.176:8103/api/comment/${id}`,{
     params:{id}
   })
 }

